package com.neutech.solar.client;

import com.neutech.solar.entity.*;
import org.jcp.xml.dsig.internal.dom.DOMUtils;

import java.util.List;
import java.awt.*;
import java.util.ArrayList;
import java.util.Random;

    public class SolarSystemClient extends AbstractFrame{
    public Background bg = new Background();
    public Sun sun = new Sun() {
    };
    Planet Mercury = new Planet(sun,"Mercury",0.387,0.2056,88,"水星");
    Planet Venus = new Planet(sun,"Venus",0.72,0.0068,225,"金星",false,true);
    Planet Earth = new Planet(sun,"Earth",1,0.0167,365,"地球");



    Planet moon = new Planet(Earth,"smallPlanet",0.3,0.0,365 / 12,"地球");


    Planet Mars = new Planet(sun,"Mars",1.52,0.0934,687,"火星");
    Planet Jupiter = new Planet(sun,"Jupiter",5.2,0.04994,4330,"木星");
    Planet Saturn = new Planet(sun,"Saturn",9.54,0.0557,10832,"土星");
    Planet Uranus = new Planet(sun,"Uranus",19.218,0.0444,30777,"天王星");
    Planet Neptune = new Planet(sun,"Neptune",30.06,0.0112,60328,"海王星");
    Planet Halley = new Planet(sun,"Venus",17.8,0.967,27485,"哈雷彗星");


    Random r = new Random();
    List<Planet> planets = new ArrayList<>();
    {
        for (int i = 0; i < 10000; i++) {
            double AU =  r.nextDouble() * 2 + 2.0;
            int T =  r.nextInt(3300)+700;
            Planet smallPlanet = new Planet(sun,"smallPlanet",AU,0.0,T ,"",true);
            planets.add(smallPlanet);
        }
    }



    public SolarSystemClient(){
        super.init("行星");
    }

    @Override
    public void paint(Graphics g) {
        bg.draw(g);
        sun.draw(g);
        Mercury.draw(g);
        Venus.draw(g);
        Earth.draw(g);
        moon.draw(g);
        Mars.draw(g);
        Halley.draw(g);


       //小行星带
        for (Planet smallPlanet : planets){
            smallPlanet.draw(g);
        }

        Jupiter.draw(g);
        Saturn.draw(g);
        Uranus.draw(g);
        Neptune.draw(g);
    }

    public static void main(String[] args) {
        new SolarSystemClient();
    }
}
